A Program To Find The GCD/HCF of Two Numbers Entered Through The Keybouard
A Program To Find The GCD/HCF of Two Numbers Entered Through The Keybouard
THE KEYBOUARD.
#include<stdio.h>/*code by siwalik*/
#include<conio.h>
main()
{
int m,n;
int gcd(int,int);
clrscr();
printf("enter m,n value:");
scanf("%d%d",&m,&n);
printf("the gcd is:%d",gcd(m,n));
getch();
}
int gcd(int m , int n)
{
if(m==0)
return n;
if(n==0)
return m;
return gcd(n, m%n);
}
#include<stdio.h>/*code by siwalik*/
#include<string.h>
#include<conio.h>
void main()
{
struct student
{
char name[20];
int roll;
int m1;
int m2;
int m3;
};
int i,j=0;
float avg;
struct student s[3];
for(i=0;i<=3;i++)
{
printf("Enter the name of student%d\n",j+1);
scanf("%s",(s[i].name));
printf("Enter the roll no. of %s\n",s[i].name);
scanf("\n%d",&s[i].roll);
printf("Enter the marks in 3 tests of %s\n",s[i].name);
scanf("%d%d%d",&s[i].m1,&s[i].m2,&s[i].m3);
avg=(s[i].m1+s[i].m2+s[i].m3)/3;
printf("\nName:%s \nRoll no:%d \nMarks in test 1:%d \nMarks in test 2:%d \nMarks in test 3:%d
\nAverage:%f\n",s[i].name,s[i].roll,s[i].m1,s[i].m2,s[i].m3,avg);
j++;
i++;
}
getch();
}
A PROGRAM TO CHECK PALINDROME OF A STRING:
#include<stdio.h>/*code by siwalik*/
#include<conio.h>
#include<string.h>
#define size 26
void main()
{
char strsrc[size];
char strtmp[size];
clrscr();
printf("\n Enter String:\t"); gets(strsrc);
strcpy(strtmp,strsrc);
strrev(strtmp);
if(strcmp(strsrc,strtmp)==0)
printf("\n Entered string \"%s\" is a palindrome",strsrc);
else
printf("\n Entered string \"%s\" is not a palindrome",strsrc);
getch();
}