- A virus

Post Top Ad

Responsive Ads Here
Share This
01 C program to print "hello world".
#include<stdio.h>
int main(){
    printf("Hello world");
    return 0;
}
 
02 C program to add two numbers in c.
#include<stdio.h>
int main(){
    int a,b,sum;
    scanf("%d %d",&a,&b);
    sum = a + b;
    printf("%d",sum);
    return 0;
} 
 
 
03 C program to accept a string from users and print it.
#include<stdio.h>
int main(){
    char str[20];
    scanf("%s",&str);
    printf("%s",str);
    return 0;
}
 
04 C program to check a given number is positive or negative. 
#include<stdio.h>
int main(){
    int num;
    scanf("%d",&num);
   
    if(num ==0)
         printf("Number is zero.");
    else if(num > 0)
printf("Number is positive.");
else
printf("Number is negative.");
    return 0;
}
 
05 C program to swap two numbers.
#include<stdio.h>
int main(){
    int a,b,c;
    scanf("%d %d",&a,&b);
   
    c = a;
    a = b;
    b = c;
    printf("%d %d",a,b);
    return 0;
}


06 C program to find area of a circle.
#include<stdio.h>
int main(){
    floar r,area;
        
    printf("Enter radius of circle: ");
    scanf("%f",&r);
    area = 3.14 * r * r;
    printf("Area of circle is: %f",area);
    return 0;
}

No comments:

Post a Comment

Post Bottom Ad

Responsive Ads Here

Pages