Saturday 22 April 2017

Program for Finding Greatest Number Using Coditional Operator in C

Program for Finding Greatest Number Using Cnoditional Operator in C

Q. Using conditional operators write a program to find out in three Numbers which is greatest number?
Ans.

#include<stdio.h>
#include<conio.h>
int main()
{
 int n1,n2,n3;
 prinft("Enter Numbers n1, n2, n3 : ");
 scanf("%d"%d%d",n1,n2,n3);
 printf("Greatest=%d",n1>n2?n1>n3?x:z:y>z?y:z);
 getch();
 return 0;
}


Output of above program : 
Enter Numbers n1, n2, n3 :10
20
30

Greatest=30

Thursday 20 April 2017

Write a program for Swapping in C

 Write a program for Swapping in C

Q. Write a simple program to insert two values through keyboard and interchange then values?
Example:if x=10
           y=20
        then after interchange 
          x=20
          y=10
Ans.

#include<stdio.h>
#include<conio.h>
int main()
{
 int x,y,z;
 printf("Enter Values x and y : ");
 scnaf("%d%d",&x,&y);
 z=y;
 y=x;
 x=z;
 printf("\nValue of x=%d",x);
 printf("\nValue of y=%d",y);
 getch(); 
 return 0;
}

        Output of above program : 
Enter Values x and y : 25
35
Value of x= 35
Value of y= 25

Tuesday 18 April 2017

C Program for Adding Two Numbers

C Program for Adding Two Numbers

Q. Write a program to add two numbers?

Ans.


#include<stdio.h>
#include<conio.h>
void main()
{
 int a,b,sum;
 clrscr();
 printf("Enter Numbers a and b : ");
 scnaf("%d%d",&a,&b);
 sum=a+b;
 printf("\nsum(a+b)=%d",sum);
 getch();
}

Output of above program : 

Enter Numbers a and b : 100
200
sum(a+b)=300

Monday 17 April 2017

Sample C program for Name,Age

Sample C program for Name,Age

Q.Write a simple C program,in which user entered his name,age through keyboard and display on console?

Ans.

/*c program to accept name & age from user and display it*/
#include<stdio.h>
#include<conio.h>
int main()
{
 char nam[20];
 int age;
 printf("Enter Your Name : ");
 scnaf("%s",&nam); // gets(nam)
 printf("Enter Your Age : ");
 scanf("%d",&age);
 printf("\nUser Name is %s",nam); 
 /*You also use puts(nam)*/
 printf("\nAnd %s age is %d",nam,age);
 getch();
 return 0;
}

Output of above program : 

Enter your name : JamesBond
Enter your age : 35

And JamesBond age is 35

What is goto Statement?

What is goto Statement?

The goto statement is used to alter the normal sequence of program instructions by transferring the control to some other portion of the program.
The syntax is as follows:
goto label;
Here, label is an identifier that is used to label the statement to which control will be transferred. The targeted statement must be preceded by the unique label followed by colon.
label: statement;
It is recommended that as possible as skip the gotostatement because when we use goto then we can never be sure how we got to a certain point in our code. They obscure the flow of control.

Note:- goto can never be used to jump into the loop from outside and it should be preferably used for forward jump.
Let us consider a program to illustrate goto and labelstatement:
/*program to demonstration of goto statement*/
#include<stdio.h>
#include<conio.h>
void main()
{
 int n;
 clrscr();
 printf("Enter one digit number: ");
 scanf("%d",&n);
 if(n<=6)
   goto mylabel;
 else
 {
   printf("Now control in main funcion.");
   exit();
 }
 mylabel:
   printf("Now control in mylabel.");
}

Output:-

Enter one digit number:9
Now control in main function.
Enter one digit number:4
Now control in mylabel. 

Sunday 16 April 2017

Program for Number Pattern in C

Program for Number Pattern in C

Q. Write a C program to display the following pattern:
 1
 2   3
 4   5    6
 7   8    9    10
11  12   13    14  15

Ans.

/*program to design the above pattern*/
#include<stdio.h>
#include<conio.h>
void main()
{
 int r,c,n=1;
 clrscr();
 for(r=1; r<=5; r++)
 {
  for(c=1; c<=r; c++)
  {
    printf("%3d",n++);
  }
  printf("\n");
 }
 getch();
}

Output:-

 1
 2   3
 4   5    6
 7   8    9    10
11  12   13    14  15

Saturday 15 April 2017

Converting String Lowercase Letter

Converting String Lowercase Letter

Q. Write a string to accept string through keyboard and convert it Lower Case letter.

Ans.

/*program to convert a string in lower case letter*/
#include<stdio.h>
#include<string.h>
int main()
{
 char str[40];
 int i;
 printf("Enter any string : ");
 gets(str);
 for(i=0; str[i]!=NULL; i++)
 {
    if(str[i]>='A' && str[i]<='Z')
    {
       str[i]=str[i]+32;
    }
 }
 str[i]='\0';
 puts(str);
 getch();
 return 0;
}

Output:-
Enter any string : My C ProgrammING CodeS
my c programming codes

Friday 14 April 2017

Converting String Uppercase Letter

Converting String Uppercase Letter

Q. Write a string to accept string through keyboard and convert it Uppercase letter.

Ans.

/*program to convert a string in upper case letter*/
#include<stdio.h>
#include<string.h>
int main()
{
 char str[40];
 int i;
 printf("Enter any string : ");
 gets(str);
 for(i=0; str[i]!=NULL; i++)
 {
   if(str[i]>='a' && str[i]<='z')
   {
      str[i]=str[i]-32;
   }
 }
 str[i]='\0';
 puts(str);
 getch();
 return 0;
}

Output:-

Enter any string : My C ProgrammING CodeS
MY C PROGRAMMING CODES

High Level Languages

High Level Languages

HLL stands for High Level Language. Basic features ofHLL is as  following:
  • These language are particularly oriented towards describing the procedures for solving the problem in a concise, precise and unambiguous manner. 
  • HLL are programming language which is user friendly, easy to learn and writing program, to extent platform independent.
  • Hll language are machine independence so its require Compiler or Translator to translate these code in machine language.
  • Examples of high level languages are C, C++, Java,FORTRAN etc.
Note: FORTRAN is first High Level Language. 

Low Level Languages

Low Level Languages

LLL is stand for Low Level Language. These language also known Machine Language. Definition and some Basic features of low level Language is as following:

  • The language whose design is governed by the circuitry and the structure of the machine is known as Machine Language.
  •  These language is difficult to learn and use.
  • These language is machine-dependent.
  • In these type language program execution is faster compere high level language because code is directed accepted by the machine, no needs to translator.
  • Example of Low level Language is the Assembly Language.

Mid Level Launguage

Mid Level Launguage

Q. Why C is called middle level language?

Ans.

It is common question in interview that why C language is called a Middle level language? Before find out this answer, you should familiar with following term:
  • HLL(High Level Language)
  • LLL(Low Level Language)
There are following reason that C is called Middle Level Language as:

  1. C programming language behaves as high level language through function, it gives a modular programming and breakup, increased the efficiency for resolvability. 
  2. C programming language support the low level language i.e. Assembly Language.
  3. C language also gives the facility to access memory through pointer.
  4. Its combines the elements of high-level languages with the functionalism of assembly language.
So, C language neither a High Level nor a Low level language but a Middle Level Language
Stay on this to get more info about programming languages

Intent in Kotlin Android Studio

 Hi larnkoders in this post you are going to learn  about, How to make pass to new activity with information or simply go to new activity on...