How to write the code for these programs ...?

Hello everybody ..
My teacher asked me to write the following programs:
1)
Write a c program that, using nested loops, displays the following pattern shown below. Your program takes from the user the number of rows as input.
Notice the case of the letters from capital to small.



2)Write a program that asks the user to type some text. Then it will count different types of characters and display the result as sown in the sample run below
(the sample run is in the link below)

http://www7.0zz0.com/2010/04/08/22/151670408.jpg



i wish to get a reply asap..
cheeers.. =D

You better have some specific problems, because you don't get the answer around here.
i have basically 2 problems
1 ) is how to make the loop shift between capital letter to small letter ..
2) is how to do "scanf" for a text ..
take a look at the sample run and u'll understand ..
I don't care about the sample run. If you've got problems, then where's your code?
And just so you know, I don't use cstdio. So I have no help to offer you on that. I use iostream. cstdio is, imo, deprecated by the existance of the ios hierarchy.
Last edited on
anasXanas wrote:
My teacher asked me to write the following programs:


Ok, how come you haven't written them?
Program1
#include<stdio.h>
int main (void)
{
int i,j,x;
// char ch;
// ch='a';

printf("Enter number of rowes \n ");
scanf("%d",&x);
for (i=0;i<=x;i++)
{

for(j=0;j<=i;j++)
{printf("%c",j);

}
printf("\n");

}

system("pause");
return 0 ;
}



program2

#include<stdio.h>
int main (void)
{
int dc,lc,uc,oc; //dc=# of digits;lc&uc=#Capital and small letters;uc =#of other characters
char ch;


printf("Enter a text \n ");
scanf("%c",&ch); // how to scan for a text instead of a single character...?

dc=0;
lc=0;
uc=0;
oc=0;
while (1)
{


scanf("%c",&ch);



if (ch>='0'&&ch<='9')
dc++;
else if (ch>='a'&&ch<='z')
lc++;
else if (ch>='A'&&ch<='Z')
uc++;
else oc++;

break;

}
printf("number of digits %d\n",dc);
printf("number of small letters %d\n",lc);
printf("number of capital letters %d\n",uc);
printf("number of other charecters %d\n",oc);

system("pause");
return 0 ;
}
Topic archived. No new replies allowed.