programs for c and c++

Posted on at


welcome in the course of computer programing.....
Introduction to Turbo C Compiler and its IDE.
How to write, compile and execute the program in Turbo C IDE?
Discuss the basic building block of C program. Also practiced different basic programs (e.g. Below) 
__________________________________________________________________________________


Program 1: simple c program
//simple c program illustrating escape sequences
#include<stdio.h>
#include<conio.h>
main ()
{
printf("welcome to C Programming\n");
printf("\twelcome to C Programming\n");
printf("welcome to C Programming\a\n");
printf("welcome to C Programming\\");
getche();
}
Analyze the output???


Program 2:
//Data types and their memory requirements
#include <stdio.h>
#include <conio.h>
int main(void)
{
printf("char is %d bytes\n", sizeof( char ));
printf("short int is %d bytes\n", sizeof( short int));
printf("int is %d bytes\n", sizeof( int ));
printf("long int is %d bytes\n", sizeof( long int));
printf("float is %d bytes\n", sizeof( float ));
printf("double is %d bytes\n", sizeof( double));
printf("long double is %d bytes\n", sizeof( long double));
getch();
return 0;}
Analyze the output????


Program 3
/*simple c program (Arithmetic operation on two integer numbers, sum is done, rest of the operation like Div, Mul, and Diff, you people try to do)
Working of printf and scanf functions */
#include<stdio.h>
#include<conio.h>
int main()
{
int integer1;
int integer2;
int sum;
printf("Enter value for Integer1\n");
scanf("%d", &integer1);
printf("Enter value for Integer2\n");
scanf("%d", &integer2);
sum=integer1+integer2;
printf("\nthe sum of integer1 and integer2 is = %d", sum);
getche();
}
Analyze the output????

 


Program 4
//increment and decrement operator heuristic
#include <stdio.h>
#include <conio.h>
int main(void)
 {
 int a=5;
 printf("\n a++ show the value of a = %d", a++);
 printf("\n%d", a);
 printf("\n ++a show the value of a = %d", ++a);
 // printf("\n --a show the value of a = %d", --a);
 // printf("\n a-- show the value of a = %d", a--);
getch();
return 0;
}
Analyze the output with different variation.??

 


 



About the author

160