0% found this document useful (0 votes)
19 views6 pages

Eval 3

Uploaded by

Navami Vinod
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views6 pages

Eval 3

Uploaded by

Navami Vinod
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

1) (A)

#include <stdio.h>

int main()
{
int i = 1, Number, Exponent;
long Power = 1;

printf("\n Please Enter any Number : ");


scanf(" %d", &Number);

printf("\n Please Enter the Exponent Vlaue: ");


scanf(" %d", &Exponent);

while(i <= Exponent)


{
Power = Power * Number;
i++;
}

printf("\n The Final result of %d Power %d = %ld", Number, Exponent,


Power);

return 0;
}

B)

#include <stdio.h>

int gcd(int a, int b)


{
if (b == 0)
return a;
return gcd(b, a % b);
}

// Driver program to test above function


int main()
{
int a = 98, b = 56;
printf("GCD of %d and %d is %d ", a, b, gcd(a, b));
return 0;
}
C)
#include <stdio.h>

int main()
{
int i, Number = 1, count;

printf(" Prime Number from 1 to 100 are: \n");


while(Number <= 100)
{
count = 0;
i = 2;
while(i <= Number/2)
{
if(Number%i == 0)
{
count++;
break;
}
i++;
}
if(count == 0 && Number != 1 )
{
printf(" %d ", Number);
}
Number++;
}
return 0;
}

2)
#include <stdio.h>
#include <string.h>

void isPalindrome(char str[])


{

int l = 0;
int h = strlen(str) - 1;

while (h > l)
{
if (str[l++] != str[h--])
{
printf("%s is not a palindrome\n", str);
return;
}
}
printf("%s is a palindrome\n", str);
}

int main()
{
isPalindrome("abba");
isPalindrome("abbccbba");
isPalindrome("geeks");
return 0;
}

You might also like