Earn by twitter on twivert

Sign up for PayPal and start accepting credit card payments instantly.

Friday, September 24, 2010

WAP to Passing address of a structure variable


/*WAP to Passing address of a structure variable */
#include<stdio.h>
#include<conio.h>
struct book 
{
 char  name[25] ;
 char  author[25] ;
 int  callno ;
} ;

main( )
{
 struct book  b1 = { "Let us C", "YPK", 101 } ;
 display ( &b1 ) ;
       getch();
}

display ( struct book  *b )
{
 printf ( "\n%s %s %d", b->name, b->author, b->callno ) ;
}

WAP to Passing individual structure elements


/*WAP to Passing individual structure elements */
#include<stdio.h>
#include<conio.h>
main( )
{
 struct book 
 {
  char  name[25] ;
  char  author[25] ;
  int  callno ;
 } ;
 struct book b1 = { "Let us C", "YPK", 101 } ;
 
 display ( b1.name, b1.author, b1.callno ) ;
 getch();
}

display ( char  *s, char  *t, int  n )
{
 printf ( "\n%s %s %d", s, t, n ) ;
}

WAP take people datail using structure


/*WAP take people datail using structure*/
#include<stdio.h>
#include<conio.h>
main( )
{
 struct address
 {
  char  phone[15] ;
  char  city[25] ;
  int  pin ;
 } ;

 struct emp
 {
  char  name[25] ;
  struct address  a ;
 } ;
 struct emp  e = { "jeru", "531046", "nagpur", 10 }; 

 printf ( "\nname = %s phone = %s", e.name, e.a.phone ) ;
 printf ( "\ncity = %s pin = %d", e.a.city, e.a.pin ) ;
       getch();
}

WAP Using a do-while loop to process a menu selection


/*WAP Using a do-while loop to process a menu selection
save file as: Menu.java
*/
class Menu {
public static void main(String args[])
throws java.io.IOException {
char choice;
do {
System.out.println("Help on:");
- 84 -
System.out.println(" 1. if");
System.out.println(" 2. switch");
System.out.println(" 3. while");
System.out.println(" 4. do-while");
System.out.println(" 5. for\\n");
System.out.println("Choose one:");
choice = (char) System.in.read();
} while( choice < '1' || choice > '5');
System.out.println("\\n");
switch(choice) {
case '1':
System.out.println("The if:\\n");
System.out.println("if(condition) statement;");
System.out.println("else statement;");
break;
case '2':
System.out.println("The switch:\\n");
System.out.println("switch(expression) {");
System.out.println(" case constant:");
System.out.println(" statement sequence");
System.out.println(" break;");
System.out.println(" // ...");
System.out.println("}");
break;
case '3':
System.out.println("The while:\\n");
System.out.println("while(condition) statement;");
break;
case '4':
System.out.println("The do-while:\\n");
System.out.println("do {");
System.out.println(" statement;");
System.out.println("} while (condition);");
break;
case '5':
System.out.println("The for:\\n");
System.out.print("for(init; condition; iteration)");
System.out.println(" statement;");
break;
}
}
}

WAP to An improved version of the season program


/*WAP to An improved version of the season program*/
class Switch {
public static void main(String args[]) {
int month = 4;
String season;
switch (month) {
case 12:
case 1:
case 2:
season = "Winter";
break;
case 3:
case 4:
case 5:
season = "Spring";
break;
case 6:
case 7:
case 8:
season = "Summer";
break;
case 9:
case 10:
case 11:
season = "Autumn";
break;
default:
season = "Bogus Month";
}
System.out.println("April is in the " + season + ".");
}
}

WAP to check that In a switch, break statements are optional


/*WAP to check that In a switch, break statements are optional*/
class MissingBreak {
public static void main(String args[]) {
for(int i=0; i<12; i++)
switch(i) {
case 0:
case 1:
case 2:
case 3:
case 4:
System.out.println("i is less than 5");
break;
case 5:
case 6:
case 7:
case 8:
case 9:
System.out.println("i is less than 10");
break;
default:
System.out.println("i is 10 or more");
}
}
}

ADS

How to earn online

How to earn online:
Step - 1 :
signup for PayPal, to recieve your online earning
click here:
https://www.paypal.com/in/mrb/pal=CZ7224TZBMCBL
step - 2 : Singup these 4 sites & earn & enjoy! Read site to know how to earn.
1. trekpay
Earn up to $0.02 (2 cents) per click.
http://www.trekpay.com/?ref=34690
2. neobux
Earn up to $0.02 (2 cents) per click.
Click here:
http://www.neobux.com/?r=Moneyearner786

AddMe

Bookmark and Share