0% found this document useful (0 votes)
4 views

C Program

The document contains examples of C programming code demonstrating basic operations like print statements, addition, subtraction, multiplication, division and for/while loops to calculate sums. Each example includes the required header file, main function, variables, operations, and print statements.

Uploaded by

Mantesh Mantesh
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

C Program

The document contains examples of C programming code demonstrating basic operations like print statements, addition, subtraction, multiplication, division and for/while loops to calculate sums. Each example includes the required header file, main function, variables, operations, and print statements.

Uploaded by

Mantesh Mantesh
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

C

PROGRAM
Ist

#include <stdio.h>
main( )
{
printf(“hello world”)
}
IInd

#include <stdio.h>
int main
{
//64+54=121
int a=64 , b=54 , add;
add= a+b; (“ addition of two numbers:%d” , add);
printf (“%d” , add);
return 0;
}
IIIrd

#include <stdio.h>
int main ( )
{
// 64-54=10
int a=64 , b=54 , subtract;
subtract= a-b; (“ subtract of two numbers:%d” , subtract);
printf (“%d” , subtract);
return 0;
}
IV th
IN C PROGRAM
#include <stdio.h> TYPE “ * ”
int main INSTEAD OF “ x ”
{
//25x2=50
int a=25 , b=2 , multiply;
multiply= axb; (“ multiply of two numbers:%d” , multiply);
printf (“%d” , multiply);
return 0;
}
Vth

#include <stdio.h>
int main
{
//25/5=5
int a=25 , b=5 , divide;
divide= a/b; (“ divide of two numbers:%d” , divide);
printf (“%d” , divide);
return 0;
}
VI th
#include <stdio.h>
int main ( ) {
int n , I , sum = 0;
printf (“Enter a positive integer:”) ;
scanf (“%d” , &n);
for (i = 1 ; i<=n ; ++i) {
sum + = I ;
}
printf (“sum=%d” , sum) ;
Return 0;
}
VII th
#include <stdio.h>
int main ( ) {
int n , i , sum = 0 ;
printf (“Enter a positive integer : “) ;
scanf (“%d” , & n );
i=1;
while (i<=n) {
sum + = 1 ;
++i ;
}
printf (“Sum = %d” , sum) ;
return 0 ;
}

You might also like