// Lab 8, Working with structs
// Programmer : Maiar Khattab
// Editor(s) used : Code Blocks 13.12
// Compiler(s) used : Code Blocks 13.12
#include<iostream>
using std:: cout ;
using std:: endl ;
#include<cstdlib>
//struct def
struct tod
{
int hour; // the hr , 0-23
int minute; // the min, 0-59
int second; //the sec, 0-59
char descr [ 32 ] ; //the description of the time of day
} ;
//void printTod(const tod&);
int main ( )
{
cout << "Lab 8, Working With structs\n " ;
cout << "Programmer: Maiar Khattab\n " ;
cout << "Editor(s) used: Code Blocks 13.12\n " ;
cout << "Compiler(s) used: Code Blocks 13.12\n " ;
cout << "File: " << __FILE__ << endl;
cout << "Complied: " << __DATE__ << " at " << __TIME__ << endl << endl;
tod theTime[ ] = { { 12 ,0 ,0 , "noon" } ,
{ 0 ,0 ,0 ," midnight" } ,
{ 6 ,00 ,00 ," supper " } ,
{ 11 ,30 ,0 ,"bedtime" } } ;
for ( int i; i < 5 ; i++ )
{
char descr [ 32 ] ;
cout << theTime[ i] .descr << " is " << theTime[ i] .hour << ':'
<< theTime[ i] .minute << ":" << theTime[ i] .second << endl;
}
}
IC8vIExhYiA4LCBXb3JraW5nIHdpdGggc3RydWN0cwovLyBQcm9ncmFtbWVyIDogTWFpYXIgS2hhdHRhYgovLyBFZGl0b3IocykgdXNlZCA6IENvZGUgQmxvY2tzIDEzLjEyCi8vIENvbXBpbGVyKHMpIHVzZWQgOiBDb2RlIEJsb2NrcyAxMy4xMgoKI2luY2x1ZGU8aW9zdHJlYW0+CnVzaW5nIHN0ZDo6Y291dDsKdXNpbmcgc3RkOjplbmRsOwoKI2luY2x1ZGU8Y3N0ZGxpYj4KCi8vc3RydWN0IGRlZgpzdHJ1Y3QgdG9kCnsKaW50IGhvdXI7Ly8gdGhlIGhyICwgMC0yMwppbnQgbWludXRlOy8vIHRoZSBtaW4sIDAtNTkKaW50IHNlY29uZDsvL3RoZSBzZWMsIDAtNTkKY2hhciBkZXNjciBbMzJdOy8vdGhlIGRlc2NyaXB0aW9uIG9mIHRo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yBuYnJlLCBtZW1vOwogICAgaW50IHNvbW1lOwoKICAgIGRvIAogICAgewogICAgICAgIHByaW50ZigmcXVvdDtWZXVpbGxleiBlbmNvZGVyIHVuIG5vbWJyZTogJnF1b3Q7KTsKICAgICAgICBzY2FuZigmcXVvdDslbGQmcXVvdDssICZhbXA7bmJyZSk7CiAgICB9CiAgICB3aGlsZSAobmJyZSAmZ3Q7PSAwKTsKCiAgICBtZW1vID0gbmJyZTsKICAgIHNvbW1lID0gMDsKCiAgICB3aGlsZSAobmJyZSAhPSAwKQogICAgewogICAgICAgIHNvbW1lICs9IG5icmUgJSAxMDsgCiAgICAgICAgbmJyZSA9IG5icmUgLyAxMDsgICAKICAgIH0KCiAgICBwcmludGYoJnF1b3Q7TGEgc29tbWUgZGVzIGNoaWZmcmVzIGRlICVsZCBlc3QgJWQuXG4mcXVvdDssIG1lbW8sIHNvbW1lKTsgCn0K
#include <stdio.h>
int main()
{
long nbre, memo;
int somme;
do
{
printf("Veuillez encoder un nombre: ");
scanf("%ld", &nbre);
}
while (nbre >= 0);
memo = nbre;
somme = 0;
while (nbre != 0)
{
somme += nbre % 10;
nbre = nbre / 10;
}
printf("La somme des chiffres de %ld est %d.\n", memo, somme);
}