[CENTER][CENTER]1
1 1 1
1 1 1 1 1
1 1 1 1 1 1 1[/CENTER]
[/CENTER]
#include <stdio.h>
main()
{
int row, col, t, i;
int tab=40;
for(row = 1; row <= 7; row++)
{
for (t = 1; t <= tab; t++) printf(" ");
/* number if blank spaces from left edge of the screen */
for(col = 1;col <= row; col++)
printf("%d ",row);
printf("\n");
tab--;
}
return 0;
}
He needed just 1s and in odd quantities only. Good write up thoughIntel_Gigacore said:Try this:
Code:#include <stdio.h> main() { int row, col, t, i; int tab=40; for(row = 1; row <= 7; row++) { for (t = 1; t <= tab; t++) printf(" "); /* number if blank spaces from left edge of the screen */ for(col = 1;col <= row; col++) printf("%d ",row); printf("\n"); tab--; } return 0; }
ilugd said:what does printf return by the way? a return value or some pointer? It would take a minute to google that but I guess that would be cheating.
#include <stdio.h>
#define MAX 10
void swap(int *x,int *y)
{
int temp;
temp = *x;
*x = *y;
*y = temp;
}
void bsort(int list[], int n)
{
int i,j;
for(i=0;i<(n-1);i++)
for(j=0;j<(n-(i+1));j++)
if(list[j] > list[j+1])
swap(&list[j],&list[j+1]);
}
void readlist(int list[],int n)
{
int i;
printf("Enter the elements\n");
for(i=0;i<n;i++)
scanf("%d",&list[i]);
}
void printlist(int list[],int n)
{
int i;
printf("The elements of the list are: \n");
for(i=0;i<n;i++)
printf("%d\t",list[i]);
}
void main()
{
int list[MAX], n;
printf("Enter the number of elements in the list max = 10\n");
scanf("%d",&n);
readlist(list,n);
printf("The list before sorting is:\n");
printlist(list,n);
bsort(list,n);
printf("The list after sorting is:\n");
printlist(list,n);
}
Intel_Gigacore said:^ theres nothing in Hint
#include<iostream>
using namespace std;
main()
{
int a, b;
cout << "Enter A and B" << endl;
cout << "a = ";
cin >> a;
cout << endl << "b = ";
cin >> b;
a = ((b - a) + (b = a));
cout << endl << "a = " << a << endl;
cout << "b = " << b;
return 0;
}
EXECUTING:
/home/aditya/test
----------------------------------------------
Enter A and B
a = 12
b = 23
a = 23
b = 12
----------------------------------------------
Program exited successfully with errcode (0)
Press the Enter key to close this terminal ...
/*
* Mail.java
*
* Created on January 1, 2003, 1:58 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package ocricket.bean;
import java.util.Date;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
/**
*
* @author Dheeraj
*/
public class Mail {
public void sendMail(String toemail, String subject, String body)
throws MessagingException {
String host = "mail.ofindia.in";
String user = "ocricket@ofindia.in";
String pass = "86qx3@i48fg6";
// Create properties, get Session
Properties props = System.getProperties();
props.put("mail.host", host);
props.put("mail.transport.protocol.", "smtp");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.", "true");
props.put("mail.smtp.port", "25");
props.put("mail.smtp.socketFactory.fallback", "false");
Session mailSession = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(mailSession);
msg.setFrom(new InternetAddress(user));
InternetAddress[] address = { new InternetAddress(toemail) };
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);
msg.setSentDate(new Date());
msg.setText(body);
Transport transport = mailSession.getTransport("smtp");
transport.connect(host, user, pass);
transport.sendMessage(msg, msg.getAllRecipients());
transport.close();
}
}
Intel_Gigacore said:I'm using borland Turbo C++, whenever i execute a program, it runs and closes suddenly... it happens in Dev C++ also.. please help