Q. If sum of two integer is 14 and if one of them is 8 then find other integer. Ans: Well, this is very simple. Simply, one integer is 8 and sum of two integers is 14. So, we need to subtract the number 8 from their sum of 14 to get the second number. So, the second number is: 14 - 8 = 6 C-Program of this task Code---> #include<stdio.h> int main () { int num1 = 8 , num2 , sum = 14 ; num2 = sum - num1 ; printf ( "The second number is: %d" , num2 ); return 0 ; }
In this C-program we will Print the "Half-Pyramid" using Alphabet(A,B,C). The range will be taken from the user.
A
AB
ABC
ABCD
ABCDE
AB
ABC
ABCD
ABCDE
input:
The Range(a letter).The input letter must be in Capital, as we created this C-Program for Capital letters.
output:
The Pattern will be printed on the screen in the given range.CODE---->
//Half-Pyramid using Alphabets
#include<stdio.h>
int main()
{
int j=0;
char alphabet='A',i='A',n;
printf(" Please, Enter a Capital Letter (no small Letter) : ");
scanf("%c",&n);
while(i<='Z') //checking, entered letter is capital.
{
if(i==n)
{
j=1;
break;
}
else
i++;
}
if(j==0)
{
printf("\n Wrong input Entered.");
exit(0);
} //Checking Ends here.
for(i='A';i<=n;i++) //Now, Printing time.
{
for(alphabet='A';alphabet<=i;alphabet++)
{
printf("%c ",alphabet);
}
printf("\n");
}
return 0;
}
Download the C-Program file of this Program.
Comments
Post a Comment