Write a C program to calculate SQUARE of given number using MACRO.
Get link
Facebook
X
Pinterest
Email
Other Apps
C File =>
/* Write a C program to calculate SQUARE of given number using MACRO. */
#include<stdio.h> #define SQUARE(x) x*x int main() { int n; printf("\n Enter number : "); scanf("%d",&n); printf("\n Square of %d is %d",n,SQUARE(n)); return 0; }
C File => /* Write a program to accept and display details of 5 students (roll no, name, percentage) using structure. */ #include<stdio.h> #include<stdlib.h> typedef struct Student { int rno; char name[50]; float perc; }; int main() { struct Student s[5]; int i; for(i=0;i<5;i++) { printf("\n\n Enter Roll no. : "); scanf("%d",&s[i].rno); printf("\n Enter Name : "); scanf("%s",s[i].name); printf("\n Enter percentage : "); scanf("%f",&s[i].perc); } printf("\n\n Given details are : "); for(i=0;i<5;i++) { ...
C File => /* Write a program to display the command line arguments in reverse order */ #include<stdio.h> #include<stdlib.h> int main(int argc,char * argv[]) { int i; for(i=argc-1;i>0;i--) printf("\n Argument [%d] is : %s",i,argv[i]); return 0; }
C File => /* Write a program to calculate sum of two numbers. Pass the numbers as command line arguments. */ #include<stdio.h> #include<stdlib.h> int main(int argc,char * argv[]) { int n=atoi(argv[1]); int m=atoi(argv[2]); int sum=n+m; printf("\n Sum of given numbers = %d",sum); return 0; }
Comments
Post a Comment
Please do not enter any spam link in message.