9.03.2011

C Basic

  •  What is language? A language is medium in which two or more object/person communicate their thought,information,data etc. C is computer language. Computer languages are generally two types:
    1. High Level Language-Translator required must example: FORTRAN
    2. Low Level Language-Not requirement translator example: machine language(0 , 1)
  •  C is a high level language with low level programming features so it is also called middle level language i.e. we can write program either in machine language(0,1) or general English keyword(HLL).
  •  C is a structured programming language,that is developed by Dennis Ritchie in 1972 at AT & Bell Laboratories in USA. 
  • Some basic tips for C Programs and C language:
    1. Each instruction in a C program is written as a separate statement. Therefore, a complete C program would comprise a series of statements.
    2. The statement in a program must appear in the same order in which we wish them to be executed, unless the result will be differ as we want wish.
    3. All statement are entered in Small case letters.
    4. Every C statement must be end with a semicolon (;). This is act that statement has been terminated
    5. C is "free form language" i.e. there are no specific rule for where the statement write.
  •  There are some other language like as C++,C# and Java, its languages are more advanced then c,then why we learn C today? There are some reason behind this question that's are following:
    1. C is the basic(mother) of all other languages.When you had learned c, you are easily deal with classes,object,template,structure,polymorphic and with familiar terminology.
    2. C++,C# and Java are OOP(Object Oriented Programming) languages.So when u creating object u must still a good command on C language.
    3. Major parts of OS(Operating System) like as Windows,UNIX,Linux are still written in C.
    4. C language is known for owns speed and execution.
    5. Today daily routine apparatus like as microwave,washing,digital camera's,microprocessor,and operating system,smart phones are worked in C programs.
    6. Maximum 3-d games are built in C.
So now let's start to learn C.

9.02.2011

12. Design numbers tringle pyramid

Q. Write a program to generate a following numbers triangle:
   (Where user entered number through keyboard, for example if num=5).
      




1



1 2


1 2 3

1 2 3 4
1 2 3 4 5
Ans.
/*c program for number triangle pyramid*/

#include<stdio.h>
#include<conio.h>
int main()
{
 int num,r,c,sp;
 printf("Enter loop repeat number(rows): ");
 scanf("%d",&num);
 for(r=1; num>=r; r++)
 {
  for(sp=num-r; sp>=1; sp--)
     printf(" ");
  for(c=1; c<=r; c++)
     printf("%d",c);
  printf("\n");
 }
 getch();
 return 0;
}

/*************OUTPUT****************
Enter loop repeat number(rows): 5





1



12


123

1234
12345

************************************/

Output of Design Numbers Triangle Pyramid C program
Figure: Screen shot of Design Numbers Triangle Pyramid C program

11.Design numbers tringle pyramid

Q. Write a program to generate a following numbers triangle:
   (Where user entered number through keyboard, for example if num=5)

                                12345
                                1234
                                123
                                12
                                1
Ans.
/*c program for number triangle pyramid*/
#include<stdio.h>

#include<conio.h>
int main()
{
 int num,c;
 printf("Enter loop repeat number(rows): ");
 scanf("%d",&num);
 for(; num>=1; num--)
 {
  for(c=1; c<=num; c++)
     printf("%d",c);
  printf("\n");
 }
 return 0;
}

/*************OUTPUT****************
Enter loop repeat number(rows): 5

                                12345
                                1234
                                123
                                12
                                1

*********************************/

9.Design numbers rectangle structure

Q. Write a program to generate a following numbers structure:
   (Where user entered number through keyboard, for example if num=5)
                            11111
                            22222
                            33333
                            44444
                            55555
                           
Ans.


#include<stdio.h>
int main()
{
 int num,r,c;
 printf("Enter loop repeat number(rows): ");
 scanf("%d",&num);
 for(r=1; num>=r; r++)
 {
  for(c=num; c>=1; c--)
     printf("%d",r);
  printf("\n");
 }
 return 0;
}

/*************OUTPUT****************
Enter loop repeat number(rows): 5

                            11111
                            22222
                            33333
                            44444
                            55555

************************************/

10. Design numbers tringle pyramid

Q. Write a program to generate a following numbers triangle:
   (Where user entered number through keyboard, for example if num=5)

                        1
                        12
                        123
                        1234
                        12345
Ans.

/* c program for number triangle*/
#include<stdio.h>
int main()
{
 int num,r,c;
 printf("Enter loop repeat number(rows): ");
 scanf("%d",&num);
 for(r=1; r<=num; r++)
 {
  for(c=1; c<=r; c++)
     printf("%d",c);
  printf("\n");
 }
 getch();
 return 0;
}

/*************OUTPUT**************
Enter loop repeat number(rows): 5

                        1
                        12
                        123
                        1234
                        12345

***********************************/


Related Pyramid Programs in C:

  1. Big List of 100+ C Pyramid Programs
  2. Latest Pyramids Programs asked By User

8.Design numbers rectangle structure

Q. Write a program to generate a following numbers structure:
   (Where user entered number through keyboard, for example if num=5)
                            55555
                            44444
                            33333
                            22222
                            11111

Ans.

/* c program for number structure*/
#include<stdio.h>
#include<conio.h>
int main()
{

7.Design numbers rectangle structure

Q. Write a program to generate a following numbers structure:
   (Where user entered number through keyboard, for example if num=5)

                                54321
                                54321
                                54321
                                54321
                                54321

Ans.

/* c program for symbol triangle*/
#include<stdio.h>
#include<conio.h>
int main()
{
 int num,r,c;
 printf("Enter loop repeat number(rows): ");
 scanf("%d",&num);
 for(r=1; num>=r; r++)
 {
  for(c=5; c>=1; c--)
     printf("%d",c);
  printf("\n");
 }
 getch();
 return 0;
}
/*************OUTPUT**************
Enter loop repeat number(rows): 5

                                54321
                                54321
                                54321
                                54321
                                54321

***********************************/